class PyTypeObject(object):
    """
    type(object_or_name, bases, dict)
    type(object) -> the object's type
    type(name, bases, dict) -> a new type
    """

    def __init__(self):
        self.container = [
            # python内置变量名,数据类型,python运行时名,对应C类型
            ("tp_bases", "PTR_OBJECT", "None", "_object *"),
            ("tp_name", "PTR_STRING", "__name__", "const char *"),
            ("tp_basicsize", "COUNTER", "None", "__int64"),
            ("tp_itemsize", "COUNTER", "None", "__int64"),
            ("tp_flags", "COUNTER", "None", "unsigned long"),
            ("tp_doc", "PTR_STRING", "__doc__", "const char *"),
            ("tp_base", "PTR_OBJECT", "__base__", "_typeobject *"),
            ("tp_dict", "PTR_OBJECT", "__dict__", "_object *"),
            ("tp_dictoffset", "COUNTER", "None", "__int64"),
            ("tp_descr_get", "PTR_FUN", "__get__", "_object *(*)(_object *, _object *, _object *)"),
            ("tp_descr_set", "PTR_FUN", "__set__, __delete__", "int(*)(_object *, _object *, _object *)"),
            ("tp_getattr", "PTR_FUN", "__getattribute__, __getattr__", "_object *(*)(_object *, char *)"),
            ("tp_setattr", "PTR_FUN", "__setattr__, __delattr__", "int(*)(_object *, char *, _object *)"),
            ("tp_getattro", "PTR_FUN", "__getattribute__, __getattr__", "_object *(*)(_object *, _object *)"),
            ("tp_setattro", "PTR_FUN", "__setattr__, __delattr__", "int(*)(_object *, _object *, _object *)"),
            ("tp_call", "PTR_FUN", "__call__", "_object *(*)(_object *, _object *, _object *)"),
            ("tp_as_async", "PTR_TFUN", "sub-slots", "PyAsyncMethods *"),
            ("tp_str", "PTR_FUN", "__str__", "_object *(*)(_object *)"),
            ("tp_richcompare", "PTR_FUN", "__lt__, __le__, __eq__, __ne__,__gt__, __ge__",
             "_object *(*)(_object *, _object *, int)"),
            ("tp_repr", "PTR_FUN", "__repr__", "_object *(*)(_object *)"),
            ("tp_hash", "PTR_FUN", "__hash__", "__int64(*)(_object *)"),
            ("tp_print", "PTR_FUN", "None", "int(*)(_object *, _iobuf *, int)"),
            ("tp_iter", "PTR_FUN", "__iter__", "_object *(*)(_object *)"),
            ("tp_iternext", "PTR_FUN", "__next__", "_object *(*)(_object *)"),
            ("tp_as_buffer", "PTR_TFUN", "None", "PyBufferProcs *"),
            ("tp_init", "PTR_FUN", "__init__", "int(*)(_object *, _object *, _object *)"),
            ("tp_new", "PTR_FUN", "__new__", "_object *(*)(_typeobject *, _object *, _object *)"),
            ("tp_free", "PTR_FUN", "None", "void(*)(void *)"),
            ("tp_finalize", "PTR_FUN", "__del__", "void(*)(_object *)"),
            ("tp_alloc", "PTR_FUN", "None", "_object *(*)(_typeobject *, __int64)"),
            ("tp_dealloc", "PTR_FUN", "None", "void(*)(_object *)"),
            ("tp_as_number", "PTR_TFUN", "sub-slots", "PyNumberMethods *"),
            ("tp_as_sequence", "PTR_TFUN", "sub-slots", "PySequence"),
            ("tp_as_mapping", "PTR_TFUN", "sub-slots", "PyMappingMetho"),
            ("tp_methods", "PTR_TFUN", "None", "PyMethodDef *"),
            ("tp_members", "PTR_TFUN", "None", "PyMemberDef *"),
            ("tp_getset", "PTR_TFUN", "None", "PyGetSetDef *"),
            ("tp_weaklist", "PTR_OBJECT", "None", "_object *"),
            ("tp_weaklistoffset", "COUNTER", "None", "__int64"),
            (
                "tp_vectorcall", "PTR_TFUN", "None",
                "_object *(*)(_object *, _object * const *, unsigned __int64, _object *)"),
            ("tp_vectorcall_offset", "COUNTER", "None", "__int64"),
            ("tp_version_tag", "COUNTER", "", "unsigned int"),
            ("tp_subclasses", "PTR_OBJECT", "__subclasses__", "_object *"),
            ("tp_cache", "PTR_OBJECT", "", "_object *"),
            ("tp_clear", "PTR_FUN", "", "int(*)(_object *)"),
            ("tp_is_gc", "PTR_FUN", "", "int(*)(_object *)"),
            ("tp_traverse", "PTR_FUN", "", "int(*)(_object *, int(*)(_object *, void *), void *)"),
            ("tp_mro", "PTR_OBJECT", "__mro__", "_object *"),
            ("tp_del", "PTR_FUN", "", "void(*)(_object *)"),
        ]


class PyObject(object):
    def __init__(self):
        self.container = [
            ("ob_refcnt", "COUNTER", "None", "__int64")
        ]
        ob_type = PyTypeObject()
        self.container.append(ob_type.container)

